package com.se.common;

import org.json.JSONObject;

import static com.se.common.Constant.*;

public class AIUser extends User {
    private String API_URL;

    private String model;

    private String api_key;

    private String AI_name;

    private String AI_ID;

    private String primaryPrompt;

    private double temperature = 1;

    public String to_String(String content) {
        JSONObject json = new JSONObject();
        json.put(API_ID, AI_ID);
        json.put(BASE_URL, API_URL);
        json.put(MODEL, model);
        json.put(API_KEY, api_key);
        json.put(MESSAGE, content);
        json.put(AI_NAME, AI_name);
        json.put(PRIMARY_PROMPT, primaryPrompt);
        json.put(TEMPERATURE, temperature);

        return json.toString();
    }

    public AIUser(String AIInfo) {
        JSONObject json = new JSONObject(AIInfo);
        API_URL = json.getString(BASE_URL);
        model = json.getString(MODEL);
        api_key = json.getString(API_KEY);
        AI_ID = json.getString(API_ID);
        temperature = json.getDouble(TEMPERATURE);
        if(!json.isNull(AI_NAME)) {
            AI_name = json.getString(AI_NAME);
        }
        if(!json.isNull(PRIMARY_PROMPT)) {
            primaryPrompt = json.getString(PRIMARY_PROMPT);
        }
    }

    public AIUser() {
    }

    public String getApi_key() {
        return api_key;
    }

    public void setApi_key(String api_key) {
        this.api_key = api_key;
    }

    public String getAPI_URL() {
        return API_URL;
    }

    public void setAPI_URL(String API_URL) {
        this.API_URL = API_URL;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public String getAI_ID() {
        return AI_ID;
    }

    public void setAI_ID(String AI_ID) {
        this.AI_ID = AI_ID;
    }

    public String getPrimaryPrompt() {
        return primaryPrompt;
    }

    public void setPrimaryPrompt(String prompt) {
        primaryPrompt = prompt;
    }

    public String getAI_name() {
        return AI_name;
    }

    public void setAI_name(String AI_name) {
        this.AI_name = AI_name;
    }

    public double getTemperature() {
        return temperature;
    }

    public void setTemperature(double temperature) {
        this.temperature = temperature;
    }

    @Override
    public String getStatus() {
        return ONLINE;
    }

    @Override
    public String getUserName(){
        return AI_name;
    }
}